//package com.yunhe.option.controller.data;
//
//import com.yunhe.option.domain.data.CostPrice;
//import com.yunhe.option.domain.data.SeasonPrice;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.PageParam;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.option.service.data.CostPriceService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.Optional;
//
//@Api(value = "costPrice", description = "用电电价维护", tags = {"Data_CostPrice"})
//@RestController
//@RequestMapping("/price/cost")
//public class CostPriceController {
//    @Autowired
//    private CostPriceService costPriceService;
//
//    @ApiOperation("新增发电电价")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(@RequestBody CostPrice costPrice)
//        throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
//        CostPrice newCostPrice = costPriceService.createCostPrice(costPrice);
//        return new ResponseEntity<>(new ResultObject(newCostPrice), HttpStatus.OK);
//    }
//
////    @ApiOperation("批量新增发电电价")
////    @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path")
////    @RequestMapping()
////    public ResponseEntity<ResultObject> batchPost(@PathVariable("systemId") Long systemId,
////                                                  @RequestBody DomainList<CostPrice> domainList)
////        throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
////        Iterable<CostPrice> newCostPrices = costPriceService.createCostPrices(domainList.getList());
////        return new ResponseEntity<>(new ResultObject(newCostPrices), HttpStatus.OK);
////    }
//
//    @ApiOperation("根据ID删除地区")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "发电电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(@PathVariable("id") Long id)
//        throws ArgumentErrorException{
//        costPriceService.delete(id);
//        return new ResponseEntity<>(new ResultObject(null), HttpStatus.OK);
//    }
//
//    @ApiOperation("更新用电电价（全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "发电电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method =  RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(@PathVariable("id") Long id,
//                                            @RequestBody CostPrice costPrice)
//        throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
//        costPrice.setId(id);
//        CostPrice newCostPrice = costPriceService.updateCostPrice(costPrice);
//        return new ResponseEntity<>(new ResultObject(newCostPrice), HttpStatus.OK);
//    }
//
//    @ApiOperation("更新用电电价（更新指定字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "发电电价ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "areaCode", value = "电价名称", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "property", value = "用电性质", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "voltageLevel", value = "电压等级", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "seasonPrice", value = "季节电价", dataType = "List<SeasonPrice>", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(@PathVariable("id") Long id,
//                                              @RequestParam("title") Optional<String> title,
//                                              @RequestParam("city") Optional<List<Long>> areaList,
//                                              @RequestParam("property") Optional<String> property,
//                                              @RequestParam("voltageLevelCode") Optional<List<Long>> voltageLevelCode,
//                                              @RequestParam("seasonPrices") Optional<List<SeasonPrice>> seasonPrices)
//        throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
//        CostPrice newCostPrice = costPriceService.updateCostPrice(id, title.orElse(null),
//                areaList.orElse(null), property.orElse(null), voltageLevelCode.orElse(null),
//                seasonPrices.orElse(null));
//        return new ResponseEntity<>(new ResultObject(newCostPrice), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据条件获得用电电价")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "queryStr", value = "查询条件", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(@RequestParam("queryStr") Optional<String> queryStr,
//                                               @RequestParam("stationId") Optional<Long> stationId,
//                                               @ModelAttribute PageParam pageParam) {
//        Iterable<CostPrice> results = costPriceService.search(queryStr.orElse(null), stationId.orElse(null), pageParam);
//        return new ResponseEntity<>(new ResultObject(results), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据电价ID获得用电电价")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "用电电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(@PathVariable("id") Long id) {
//        CostPrice gp = costPriceService.findById(id).get();
//        return new ResponseEntity<>(new ResultObject<>(gp), HttpStatus.OK);
//    }
//}
